<?

/******* embed lang data *********/
if (function_exists('mb_internal_encoding'))
	mb_internal_encoding("UTF-8");
	
$DATA['langs'] = array();

if ($dbReady && ($l = datafetch('db_list', array('table' => tb('list'), 
		'where' => 'id_list='.L_LANGS.' AND '.dbAndL('attr', LL_CORE | LL_ACTIVE | LL_ADMIN), 
		'order' => 'id_index', 'index' => 'text')))) {
	
	foreach($l as $id => $v) {
		if ($v['attr'] & LL_DEFAULT) {
			$DATA['langs'][$id] = $v;
			unset($l[$id]);
			break;
		}
	}

	foreach($l as $id => $v) {
		if ($v['attr'] & LL_ACTIVE) {
			$DATA['langs'][$id] = $v;
			unset($l[$id]);
		}
	}

	foreach($l as $id => $v) {
		if ($v['attr'] & LL_ADMIN) {
			$DATA['langs'][$id] = $v;
			unset($l[$id]);
		}
	}

	foreach($l as $id => $v)
		$DATA['langs'][$id] = $v;

	foreach($DATA['langs'] as $id => $v) {
		if (!defined('LANG_DEF') && ($v['attr'] & LL_DEFAULT)) {
			define('LANG_DEF',	$v['text']);
			define('LANG_DEF_NAME',	$v['assoc']);
		}
		if (!defined('LANG_ADMIN') && ($v['attr'] & LL_ADMIN)) {
			define('LANG_ADMIN',	$v['text']);
		}
	}

} else {
	
	define('LANG_DEF',		'uk');	// default site language (this lang uses for page names in struct table)
	define('LANG_DEF_NAME',	'українською');
	
	define('LANG_ADMIN',		'ru');	// default admin language
	
	$DATA['langs'] = array(LANG_DEF => array('assoc' => LANG_DEF_NAME, 'text' => LANG_DEF));
}

/******* end of embed lang data *********/

// common const here

$STATIC = array();
